<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/manage/common/taglibs.jsp" %>
<div class="body" style="position: relative">
    <div style="position: absolute;left: 20px;top:10px ; width: 70px; text-align: center;color: #47a6f5;cursor:pointer;border: 1px solid  #47a6f5;line-height: 28px"
         onclick="manage_sys_opens('中心机房','/manage/demo/powerPage/tosecondaryPages.html')">返回</div>
<div class="container"><div class="EMStop1"></div></div>
<div class="container1">
    <div class="EMSUspContent"><p class="EMStitle" style="position: absolute;top:40px ;position: relative">红外感应器数据</p>
        <div class="content">
            <div class="left">
                <div class="upsSd" style=" background-image: url('/manage/assert/image/kongkai.png');">
                    <div class="loading" id="box">

                    </div>
                </div>
                <p>连接状态 :<span class="linkSuccess"></span></p>
            </div>
            <div style="height: 300px;">
                <div class="right"style="height: 70px;margin-top: 115px">
                <table id="infraredinduction_table" border="2">
                    <tr>
                        <th class="blueBg">设备状态</th>
                        <td ><span name="state"></span></td>
                        <th class="blueBg">电池状态</th>
                        <td><span name="batterystate"></span></td>
                    </tr>
                    <tr>
                        <th class="blueBg">防拆状态</th>
                        <td><span name="tamperstate"></span></td>
                        <th class="blueBg">按键状态</th>
                        <td><span name="keystate"></span></td>
                    </tr>
                    <tr>
                        <th class="blueBg">电压</th>
                        <td><span name="voltage"></span></td>
                        <th class="blueBg"></th>
                        <td><span name=""></span></td>
                    </tr>

                </table>
            </div>
            </div>
        </div>
    </div>
</div>

</div>
<script>
    $(function () {
        var count = 0;
        var t = setInterval(function () {
            var $redDiv = $("#box").find(".greenBg");
            if(count === 15){
                count=-1;
                $("#box").find('.greenBg').removeClass('greenBg').addClass('white');
                $redDiv=$("#box").find(".first");
                $("#box").find(".last").removeClass("greenBg").addClass("white");
            }
            $redDiv.next().removeClass("white").addClass("greenBg");
            count++;
        }, 1000);
        //if($.websocket.socketMsgs) {
        $.post("/manage/demo/equipment/fetchLastData.html?eids="+ $.websocket.hwgyq,function (entity) {
           // var entity = $.websocket.hwgyqall
            //var entity = JSON.parse(socketMsg.entity)
            if (entity.equipmentid == $.websocket.hwgyq) {//红外感应器数据
                if (entity.state == '00') {
                    $("#infraredinduction_table span[name='state']").text('正常');
                }
                if (entity.state == '10') {
                    $("#infraredinduction_table span[name='state']").text('故障');
                }
                if (entity.state == '01') {
                    $("#infraredinduction_table span[name='state']").text('告警');
                }
                if (entity.keystate == '000') {
                    $("#infraredinduction_table span[name='keystate']").text('正常');
                } else if (entity.keystate == '001') {
                    $("#infraredinduction_table span[name='keystate']").text('测试');
                }
                if (entity.batterystate == '00') {
                    $("#infraredinduction_table span[name='batterystate']").text('正常');
                } else if (entity.batterystate == '01') {
                    $("#infraredinduction_table span[name='batterystate']").text('低电');
                }
                if (entity.tamperstate == '0') {
                    $("#infraredinduction_table span[name='tamperstate']").text('正常');
                } else if (entity.tamperstate == '1') {
                    $("#infraredinduction_table span[name='tamperstate']").text('被拆');
                }
                //$("#infraredinduction_table span[name='batterystate']").text(entity.batterystate);
                //$("#infraredinduction_table span[name='tamperstate']").text(entity.tamperstate);
                //$("#infraredinduction_table span[name='keystate']").text(entity.keystate);
                $("#infraredinduction_table span[name='voltage']").text(entity.voltage);
            }
        })
        //}
    });
</script>